package com.xzit.rcpyxt.service.impl;

import com.xzit.rcpyxt.dto.CourseDto;
import com.xzit.rcpyxt.dto.TeacherDto;
import com.xzit.rcpyxt.entity.Course;
import com.xzit.rcpyxt.entity.TeacherClass;
import com.xzit.rcpyxt.mapper.CourseMapper;
import com.xzit.rcpyxt.service.CourseService;
import com.xzit.rcpyxt.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseMapper courseMapper;

    @Override
    public PageUtil findByCourseList(CourseDto courseDto) {
        int page = courseDto.getPage();
        int pageSize = courseDto.getPageSize();
        courseDto.setPage(page - 1);
        courseDto.setPageSize(page * pageSize);
        List<Course> teachers = courseMapper.selectByCourseList(courseDto);
        int totalElements = courseMapper.countByCourseList();
        return new PageUtil(page, pageSize, totalElements, teachers);
    }

}
